
class Parser:
    def __init__(self, input: str) -> None:
        self._idx = 0
        self._input = input

    def char(self):
        return self._input[self._idx]
    
    def parse_atom(self):
        if self.char() == '(':
            self._idx += 1
            value = self.parse_expr()
            self._idx += 1
            return value
        return self.parse_int()
    
    def parse_expr(self):
        result = self.parse_atom()
        while self._idx < len(self._input) and self.char() != ')':
            oper = self._input[self._idx + 1]
            self._idx += 3
            if oper == '*':
                result *= self.parse_atom()
            else:
                result += self.parse_atom()
        return result
    
    def parse_int(self):
        start = self._idx
        while self._idx < len(self._input) and self.char().isdigit():
            self._idx += 1
        return int(self._input[start:self._idx])

with open('input.txt') as file:
    result = 0 
    for line in file.read().splitlines():
        result += Parser(line).parse_expr()
    print(result)